home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -websites- / wirenet / files / thor25_arexx.lha / GoldED / FindFile.ged < prev    next >
Text File  |  1996-10-26  |  3KB  |  146 lines

  1. /* FindFiles.ged by Troels Walsted Hansen
  2. ** With searchcode by Eivind Nordseth
  3. ** $VER: FindFiles.ged v1.00 (09.06.95)
  4. **
  5. ** An ARexx script that finds files matching a search pattern on
  6. ** a chosen bbs and inserts the file information into the GoldED
  7. ** you are currently using.
  8. **
  9. ** History:
  10. ** ¯¯¯¯¯¯¯¯
  11. ** FindFiles.ged v1.05 (11.06.95)
  12. **  · now uses only ONE function from THOR...
  13. */
  14.  
  15. options results
  16.  
  17. /* needs GoldED, THOR and bbsread.library functions */
  18.  
  19. if(substr(address(),1,6) ~= "GOLDED") then
  20. do
  21.     say "This script should only be started from inside GoldED."
  22.     exit 20
  23. end
  24. else gedport = address()
  25.  
  26. p = ' ' || address() || ' ' || show('P',,)
  27. thorport = pos(' THOR.',p)
  28.  
  29. if thorport > 0 then thorport = word(substr(p,thorport+1),1)
  30. else
  31. do
  32.     say 'No THOR port found!'
  33.     exit 10
  34. end
  35.  
  36. if ~show('p', 'BBSREAD') then
  37. do
  38.     address command
  39.         "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  40.         "WaitForPort BBSREAD"
  41. end
  42.  
  43. /* get bbsname */
  44.  
  45. address (bbsread)
  46. GETBBSLIST stem BBSLIST
  47. if(rc ~= 0) then
  48. do
  49.     address(gedport)
  50.     REQUEST PROBLEM '"'BBSREAD.LASTERROR'"'
  51.     exit 5
  52. end
  53.  
  54. address(thorport)
  55. THORTOFRONT
  56.  
  57. REQUESTLIST instem BBSLIST title '"Select BBS:"' SIZEGADGET
  58. if(rc ~= 0) then exit
  59. else bbs = result
  60.  
  61. /* get searchpattern */
  62.  
  63. address(gedport)
  64. REQUEST BODY '"Please enter search pattern:"' TITLE '"Find file..."' VAR pattern STRING
  65. if(rc ~= 0 | pattern = "") then exit
  66.  
  67. address (bbsread)
  68. SEARCHBRFILE bbsname '"' || bbs || '"' stem SRESULT search '"' || pattern || '"' keyword
  69.  
  70. if(result > 0) then
  71. do
  72.     do f=1 to SRESULT.FILEAREA.COUNT
  73.         address(gedport)
  74.         CR
  75.         TEXT T '"' || '(' || SRESULT.FILEAREA.f || ')' || '"'
  76.         CR
  77.  
  78.         do i=1 to SRESULT.FILE.f.COUNT
  79.             call showfiledata('"' || bbs || '"', '"'|| SRESULT.FILEAREA.f || '"', SRESULT.FILE.f.i, gedport)
  80.         end
  81.     end
  82. end
  83. else
  84. do
  85.     address(gedport)
  86.     REQUEST BODY '"No files found."' BUTTON '"_Ok"' TITLE '"Find file..."'
  87. end
  88.  
  89. exit
  90.  
  91. /* Procedure to show the data about a file */
  92.  
  93. showfiledata: procedure
  94.     parse arg bbs,farea,filenr,gedport
  95.  
  96.     FDF_DELETED = '00000001'x
  97.  
  98.     drop FILE.    /* Important */
  99.  
  100.     address (bbsread)
  101.     READBRFILE bbs farea filenr tagsstem FILE datastem DATA
  102.  
  103.     nextfile = result
  104.  
  105.     if (bitand(DATA.FLAGS,FDF_DELETED) ~= FDF_DELETED) then
  106.     do
  107.         if(symbol("FILE.DATE") = "VAR") then fdate = FILE.DATE
  108.         else date = DATA.FILEDATE
  109.  
  110.         AMIGA2DATE fdate CD
  111.         fdatestr = right(CD.YEAR, 2) || right('0'||CD.MONTH, 2) || right('0'||CD.MDAY, 2)
  112.  
  113.         if(symbol("FILE.SIZE") = "VAR") then fsize = FILE.SIZE
  114.         else size = "Unkn"
  115.  
  116.         if(symbol("FILE.DOWNLOADS") = "VAR") then fdnls = FILE.DOWNLOADS
  117.         else fdnls = "Unkn"
  118.  
  119.         if(symbol("FILE.DESCRIPTION.COUNT") = "VAR") then descr = FILE.DESCRIPTION.1
  120.         else descr = "NONE"
  121.  
  122.         address(gedport)
  123.         TEXT T '"' || left(FILE.NAME,16) || " " || fdatestr || " " || right(fsize,7) || right(fdnls,4) || " " || descr || '"'
  124.         CR
  125.  
  126.         if(descr ~= "NONE") then
  127.         do
  128.             if(FILE.DESCRIPTION.COUNT > 1) then
  129.             do
  130.                 do n=2 to FILE.DESCRIPTION.COUNT
  131.                     address(gedport)
  132.                     TEXT T '"' || left("",33) || FILE.DESCRIPTION.n || '"'
  133.                     CR
  134.                 end
  135.             end
  136.         end
  137.     end
  138.     else
  139.     do
  140.         address(gedport)
  141.         TEXT T '"' || 'File is deleted.' || '"'
  142.         CR
  143.     end
  144.  
  145.     return nextfile
  146.